A data engineer is working with two tables. Each of these tables is displayed below in its entirety.
The data engineer runs the following query to join these tables together:
Which of the following will be returned by the above query?
Answer: C
Option Analysis:
A. Incorrect. Option A typically returns 4 rows including an unmatched row for customer 2 with null order values, which is the output of a LEFT OUTER JOIN, not the inner join specified in the query. This distractor targets common confusion between inner and left outer join behavior, a frequently tested exam concept.
B. Incorrect. Option B typically returns 2 rows, incorrectly deduplicating the two matching entries for customer 1. This error reflects a misunderstanding of join cardinality, as joins return all valid matching row pairs rather than deduplicating duplicate key values, making this option invalid.
C. Correct. Option C exactly matches the output of the specified inner join, returning all valid matching row pairs from both tables with no unmatched rows from either source. This adheres to ANSI SQL join standards required for the Data Engineer Associate certification, confirming it is the correct answer.
D. Incorrect. Option D typically returns 4 rows including all unmatched rows from both tables with null values for missing columns, which is the output of a FULL OUTER JOIN, not the query provided. This distractor tests the ability to differentiate use cases for different join types, a core exam competency.
Key Concepts:
1. ANSI SQL Inner Join Behavior: Inner joins retain only rows where the specified join key values exist in both input tables, excluding all unmatched rows from either source, unlike outer join variants that retain unmatched rows from one or both tables.
2. Join Cardinality: When a join key has duplicate values in one or both input tables, the join returns the Cartesian product of all matching rows, so a key appearing N times in the first table and M times in the second will produce N*M matching rows in the output.
3. Null Value Handling in Joins: Per ANSI SQL standards, null is treated as unequal to all values including other nulls, so rows with null values in the join key are automatically excluded from inner join results.
References:
Join fundamentals, Microsoft Learn, https://learn.microsoft.com/en-us/sql/relational-databases/performance/joins?view=sql-server-ver16
Working with joins in AWS Glue, AWS Documentation, https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-transforms-join.html